package com.glas.app;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.awt.BorderLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.Scanner;

import javax.swing.*;

/**
 * 入口类
 */
@Slf4j
@Component
public class GlasStart {

    // TODO 读取一个项目中的所有 Entity 类
    public void getAllEntity(){

    }


    public static void main(String[] args) throws IOException {

        while (true){

            Scanner scanner = new Scanner(System.in);
            System.out.println("Please enter something and press enter");

            String input = scanner.nextLine();
            System.out.println("You entered: " + input);

//            scanner.close();

            JFrame frame = new JFrame("InputBox Example");
//            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 关闭叉时，会关闭整个程序
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);// 不会关闭程序
            frame.setSize(300, 200);

            JPanel panel = new JPanel();
            JLabel label = new JLabel("Enter some text:");
            JTextField textField = new JTextField(20);
            JButton button = new JButton("Confirm");

            panel.add(label);
            panel.add(textField);
            panel.add(button);
            frame.add(panel, BorderLayout.CENTER);

            button.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    String input = textField.getText();
                    // 将输入的内容发送到后台进行处理
                    sendInputToBackend(input);
                    // 关闭窗口
                    frame.dispose();
                }
            });

            frame.setVisible(true);

        }


    }

    // 发送输入内容到后台进行处理的方法，这里只是简单地打印出来作为示例
    private static void sendInputToBackend(String input) {
        System.out.println("Received input: " + input);
    }





}
